<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Key Detection</title>
  <script type="text/javascript" src="https://www.cornify.com/js/cornify.js"></script>
</head>

<body>
  <script>
    let keyArr = [];
    const secretCode = 'wesbos';
    window.addEventListener("keyup", e => {
      keyArr.push(e.key);
      // splice(startIdx, deleteCount)：当起始位置为负数时表示倒数第n个
      keyArr.splice(-secretCode.length - 1, keyArr.length - secretCode.length);
      if (keyArr.join("").includes(secretCode)) {
        console.log('DING DING!');
        cornify_add();
      }
    })
  </script>
</body>

</html>